﻿@model RBS.Web.Hotel.Models.Dine.OrderViewModel
@using RBS.Core.Extension
@using RBS.Web.Hotel.Models.Dine

@{
    ViewBag.Title = "订单详细";
    Layout = "~/Views/Shared/_Layout.cshtml";
    var operateList = ViewBag.OperateList == null ? null : (IList<RBS.Web.Hotel.Models.Dine.OperateRecordViewModel>)ViewBag.OperateList;
}


<!--导航栏-->
@{
    @Html.Partial("_Location");
}
<script src="~/Scripts/Raty/jquery.raty.min.js"></script>
<!--/导航栏--> 

<!--内容-->


<div class="content-tab-wrap">
    <div id="floatHead" class="content-tab">
        <div class="content-tab-ul-wrap">
            <ul>
                <li><a href="javascript:;" onclick="tabs(this);" class="selected">订单信息</a></li> 
                <li><a href="javascript:;" onclick="tabs(this);" >菜谱信息</a></li> 
            </ul>
        </div>
    </div>
</div> 
<div class="tab-content" style="padding: 10px;"> 
    <table class="ltable"> 
        <tr>
            <td>订单状态 :
                @Html.Raw(Model.OrderState.ToString())
            </td>
       
            <td>订单渠道:
                @Html.Raw(Model.OrderChannel.ToString())
            </td>
            <td></td>
        </tr>
        <tr>
            <td>联 系 人 : 
                @Html.Raw(Model.ContactUser)
            </td> 
            <td>预订手机 :
                @Html.Raw(Model.ContactMobile)
            </td>
        
            <td>预订金额 :
                @Html.Raw(new RBS.Core.BLL.D_Order_Details().GetOrderMoney(Model.OrderID).ToString("N2"))
            </td>
        </tr>
        <tr> 
            <td>预定时间 :
                @Html.Raw(Model.OrderTime.ToString("yyyy-MM-dd HH:mm"))
            </td>
        
            <td>吃饭人数 :
                @Html.Raw(Model.DineNum)
            </td>
        
            <td>桌位 :
                @Html.Raw(Model.DineTable)
            </td>
        </tr>  
    </table>
     <div class="line5"></div>
      <table border="0" cellspacing="0" cellpadding="0" class="ltable">
         
                    @if (operateList != null && operateList.Any())
                    {
                        foreach (var item in operateList)
                        {
                            <tr>
                                <td align="left">@Html.Raw(item.OperateDesc)</td>
                                <td align="left">@item.OperateDate.ToString("yyyy-MM-dd HH:mm:ss")</td> 
                                <td align="left">@Html.Raw(item.OperateUser)</td>
                            </tr>
                        }
                    }
                    else
                    { 
                        <tr>
                            <td colspan="3">没有操作记录</td>
                        </tr>
                    }
                </table>
    <div class="line5"></div>
    @{
        if (ViewBag.orderComment != null)
        {
             <table class="ltable">
               
                    <tr>
                         <td>口味：</td> <td>  <div id="weidao" data-score="@ViewBag.orderComment.weidao"></div></td> </tr> 
                        <tr> <td>环境：</td> <td>  <div id="jchj" data-score="@ViewBag.orderComment.jchj"></div></td> </tr> 
                         <tr><td>服务：</td> <td>  <div id="Column_8" data-score="@ViewBag.orderComment.Column_8"></div></td>  </tr> 
                        <tr> <td>内容：</td> <td>@Html.Raw(@ViewBag.orderComment.Comments)</td> </tr>  
          </table> 
        }
    }
         
      
</div>
 <div class="line5"></div>
@* <div class="content-tab-wrap">
    <div id="floatHead" class="content-tab">
        <div class="content-tab-ul-wrap">
            <ul>
                <li><a href="javascript:;" onclick="tabs(this);" class="selected">菜单信息</a></li> 
            </ul>
        </div>
    </div>
</div>*@

<div class="tab-content" style="padding: 10px; display: none">
    <table   class="ltable">
        <tr> 
            <th>菜名</th>
            <th>数目</th>
            <th>价格</th>
            <th>优惠价格</th>
            <th align="left">状态</th>
        @*    <th>时间</th>*@
      
        </tr>
        @if (null != Model && Model.OrderDetails != null && Model.OrderDetails.Any())
        {
            foreach (var item in Model.OrderDetails)
            {
            <tr style="text-align: center"> 
                <td>
                    @Html.DisplayFor(modelItem => item.CName)
                </td>
                <td>
                    @Html.DisplayFor(modelItem => item.Num)
                </td>
                <td>
                    @Html.DisplayFor(modelItem => item.Price)
                </td>
                <td>
                    @Html.DisplayFor(modelItem => item.DisAmount)
                </td>
                <td>
                    @{
                      var ReminderDishList = new RBS.Core.BLL.D_ReminderDish().GetModelList(" OrderId='" + item.OrderId + "' and OrderDetailid='" + item.Id + "' and cookbookid='" + item.HCId + "' ");
                        <ul style="text-align: left"> 
                      @foreach (var dReminderDish in ReminderDishList)
                        {
                             <li>@dReminderDish.ReminderDish : @dReminderDish.ReminderDishTime.ToString("HH:ss") @dReminderDish.HU_Id </li>
                        }
                      </ul> 
                   }
                </td>
              @*  <td>
                    @Html.DisplayFor(modelItem => item.OperateDate)
                </td> *@
            </tr>
            }
             <tr style="text-align: center"> 
                <td>
                
                </td>
                <td> 
                </td>
                <td>
                  @{
                    @Model.OrderDetails.Sum(c => c.Price * c.Num); 
                  }
                </td>
                <td>
                    @Model.OrderDetails.Sum(c => c.DisAmount * c.Num)
                </td>
                <td>
                  
                </td>
              @*  <td>
                    @Html.DisplayFor(modelItem => item.OperateDate)
                </td> *@
            </tr>
        }
    </table> 
  @*  
    下单时间，开始烹调时间，烹调完成时间，传菜时间，厨师，传菜员，等信息，时间的表达仅用时分秒即可，不用日期
*@
</div>  
<!--/内容-->

<!--工具栏-->
<div class="page-footer">
    <div class="btn-list">
        <input name="btnReturn" type="button" value="返回上一页" class="btn yellow" onclick="javascript: history.back(-1);" />
        @if (Model.IsCanConfirm)
        { 
            <input type="button" id="btnConfirm" value="订单确认" class="btn" />
        }
        @if (Model.IsCanCancel)
        { 
            <input type="button" id="btnCancel" value="订单取消" class="btn" />
        }
        @if (Model.IsCanCheckout)
        { 
            <input type="button" id="btnCheckout" value="结算订单" class="btn" />
        }
    </div>
    <div class="clear"></div>
</div>
<!--/工具栏-->

<script type="text/javascript">

    $(function () {

        $("#btnConfirm").click(function () {
            confirmOrder("@Model.OrderID");
        });
        $("#btnCancel").click(function () {
            cancelOrder("@Model.OrderID");
        });
        $("#btnCheckout").click(function () {
            checkoutOrder("@Model.OrderID");
        });


    });
    //确认订单
    var confirmOrder = function (orderId) {
        $.dialog.confirm("确定确认订单信息？", function () {
            $.post("/Dine/ConfirmOrder", { OrderId: orderId }, function (data) {
                if (data.IsSuccess) {
                    $.dialog.alert("订单确认成功！");
                } else {
                    $.dialog.alert("订单确认失败！");
                }
            });
        });
    };
    //取消订单
    var cancelOrder = function (orderId) {
        $.dialog.confirm("确定取消订单信息？", function () {
            $.post("/Dine/CancelOrder", { OrderId: orderId }, function (data) {
                if (data.IsSuccess) {
                    $.dialog.alert("订单取消成功！");
                } else {
                    $.dialog.alert("订单取消失败！");
                }
            });
        });
    };
    //结算订单
    var checkoutOrder = function (orderId) {
        $.dialog.confirm("确定结算订单信息？", function () {
            $.post("/Dine/CheckoutOrder", { OrderId: orderId }, function (data) {
                if (data.IsSuccess) {
                    $.dialog.alert("订单结算成功！");
                } else {
                    $.dialog.alert("订单结算失败！");
                }
            });
        });
    };


    //状态跟踪 
    var Operate = function (orderdetailId) {
        $.dialog({
            id: 'OD',
            lock: true,
            title: '状态跟踪',
            width: '710px',
            height: '520px',
            content: "url:@Url.Action("Operate")/" + orderdetailId,
            ok: function () {
                this.close();
                return false;
            }
        });
    };
    

    $('#weidao').raty({
        readOnly: true,
        score: function () {
            return $(this).attr('data-score');
        }
    });
    $('#jchj').raty({
        readOnly: true,
        score: function () {
            return $(this).attr('data-score');
        }
    });
    $('#Column_8').raty({
        readOnly: true,
        score: function () {
            return $(this).attr('data-score');
        }
    });
</script>



